<template>
    <BaseContainer>
        <aplid-base-crud ref="crud" class="w-100" v-bind="baseConfig">
            <template #assessmentFile1="{ row }">
                <el-text v-if="row.assessmentFile" type="primary" @click="openDialog(row)" style="cursor: pointer;">
                    查看
                </el-text>
                <el-text v-else type="primary" @click="openEdit(row)" style="cursor: pointer;">
                    上传
                </el-text>
            </template>
        </aplid-base-crud>
        <AplidDialog width="60%" title="查看" v-model="showView">
           <ViewList :viewList="fileList" type="pdf"></ViewList>
        </AplidDialog>
    </BaseContainer>
</template>

<script setup lang="ts">
import {baseConfig} from './config'
import ViewList from '../imgPdfPreview/list.vue'
import { getBaseAreaData } from '@/utils/util'
import { getStore } from '@/utils/store'
import { ref, nextTick} from 'vue'

let crud = ref()
let showView = ref(false)
let fileList = ref([])
const openDialog = (row) =>{
    fileList.value = row.assessmentFile.split(',')
    showView.value = true
}
const openEdit = (row) =>{
    // 处理编辑和删除控制
	let userInfo = getStore('userInfo')
	if (userInfo.classifyId == 3) {
		// 行政用户，用区域判断
		if (getBaseAreaData(row).myAreaId == getBaseAreaData(userInfo).myAreaId&&row.authOrganizationId==userInfo.organizationId) {
			nextTick(() => {
				crud.value.handleOperate('edit', row, '编辑')
			})
		} else {
			ElMessage.warning('您没有权限编辑该条数据')
		}
	} else if (userInfo.classifyId == 5) {
		// 服务商
		if (row.authOrganizationId == userInfo.organizationId) {
			nextTick(() => {
				crud.value.handleOperate('edit', row, '编辑')
			})
		} else {
			ElMessage.warning('您没有权限编辑该条数据')
		}
	}else{
		ElMessage.warning('您没有权限编辑该条数据')
	}
    
} 

</script>
<style scoped lang="scss">
</style>